@require "./variables.styl"

color-yiq($color)
  $r = red($color)
  $g = green($color)
  $b = blue($color)
  $yiq = (($r * 299) + ($g * 587) + ($b * 114)) / 1000
  if $yiq >= $yiq-contrasted-threshold
    return $yiq-text-dark
  else
    return $yiq-text-light

relative()
  position relative

absolute()
  position absolute

abs-full()
  absolute()
  top 0
  left 0
  right 0
  bottom 0

abs-center(w, h)
  w = unit(w, px)
  h = unit(h, px)
  absolute()
  top 50%
  left 50%
  margin-left (- w / 2)
  margin-top (- h / 2)

abs-center-transform()
  absolute()
  top 50%
  left 50%
  transform translate(-50%, -50%)

text-break-words()
  white-space normal
  word-break break-all

text-no-wrap()
  white-space nowrap

ellipse()
  text-overflow ellipsis
  overflow hidden

f-border($color = #eee, $weight = 1px)
  border solid $weight $color

f-placeholder($color = $color-df-input-placeholder)
// Firefox
  &::-moz-placeholder
    color $color
    opacity 1 // Override Firefox's unusual default opacity; see https://github.com/twbs/bootstrap/pull/11526
  &:-ms-input-placeholder
    color $color // Internet Explorer 10+
  &::-webkit-input-placeholder
    color $color // Safari and Chrome

form-control-focus($color = $color-df-input-border-focus)
  &:hover:not([disabled]), &.hover:not([disabled])
    border-color $color
  &:focus:not([disabled]), &.focus:not([disabled])
    border-color $color
    outline 0
    box-shadow inset 0 1px 1px rgba(0,0,0,.075), 0 0 8px rgba(red($color), green($color), blue($color), .6)

